

import UIKit


enum AppEnvType {
    case dev
    case pre
    case pro
}

let screenWidth = UIScreen.main.bounds.size.width
let screenHeight = UIScreen.main.bounds.size.height
let screenBounds = UIScreen.main.bounds
let statusBarHeight = UIApplication.shared.statusBarFrame.size.height
let tabBarHeight: CGFloat = statusBarHeight > 20 ? 83 : 49
let tabBarContentHeight: CGFloat = statusBarHeight > 20 ? 64 : 49

var tabBarSafeBottomMargin: CGFloat {
    isIPhoneX() ? 34 : 0
}

let navBarHeight: CGFloat = statusBarHeight + 44

private func isIPhoneX() -> Bool {
    if let bottom = UIApplication.shared.delegate?.window??.safeAreaInsets.bottom {
        return bottom > 0
    }
    return false
}
 
let kDevBundleId = "com.xia.SCA"
let kProBundleId = "com.xia.SCA"
let kBaseDomainsKey = "baseDomains"
let kBaseRequestPathKey = "baseRequestPath"


private let appConfiguration: [String: Any] = {
    return [
        kBaseDomainsKey: [
            AppEnvType.dev: "sca-test.applinkapi.com",
            AppEnvType.pre: "newa3.testrunsystem.com",
            AppEnvType.pro: "sca-test.applinkapi.com"
        ],
        kBaseRequestPathKey: [
            AppEnvType.dev: "sca-test.applinkapi.com/api/metaAi",
            AppEnvType.pre: "newa3.testrunsystem.com/sca/api",
            AppEnvType.pro: "sca-test.applinkapi.com/api/metaAi"
        ]
    ]
}()

func getAppEnvType() -> AppEnvType {
    if getAppBundleIdentifier() == kProBundleId {
        return .dev
    }
    return .pre
}

func isDevelopment() -> Bool {
    return getAppEnvType() == .dev
}

func isProduction() -> Bool {
    return getAppEnvType() == .pro
}

func getAppId() -> String {
    return ""
}

func getAppsFlyerKey() -> String {
    return ""
}

func getBaseDomains() -> String {
    let res = appConfiguration[kBaseDomainsKey] as! [AppEnvType: String]
    return res[getAppEnvType()]!
}
 
func getBaseUrlString() -> String {
    let res = appConfiguration[kBaseRequestPathKey] as! [AppEnvType: String]
    let requestPath = res[getAppEnvType()]!
    return "https://\(requestPath)"
}

func getDeviceSystemVersion() -> String {
    return UIDevice.current.systemVersion
}

func getAppVersion() -> String {
    return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String
}

func getAppName() -> String {
    return Bundle.main.infoDictionary?["CFBundleDisplayName"] as! String
}

func getAppBundleIdentifier() -> String {
    return Bundle.main.infoDictionary?["CFBundleIdentifier"] as! String
}

func getUserAgent() -> String {
    return "Mozilla/5.0 \(Bundle.main.infoDictionary?[kCFBundleExecutableKey as String] ?? Bundle.main.infoDictionary?[kCFBundleIdentifierKey as String] ?? "")/\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] ?? Bundle.main.infoDictionary?[kCFBundleVersionKey as String] ?? "") (\(UIDevice.current.model); iOS \(UIDevice.current.systemVersion); Scale/\(UIScreen.main.scale))"
}

func getBuglyAppId() -> String {
    return ""
}
 


 
